package org.op.editor.doc;

import javax.swing.text.AttributeSet;
import javax.swing.text.Document;

import org.op.FrameView;
import org.op.editor.EditorComponentView;
import org.op.service.config.ConfigurationService;
import org.op.service.doc.StyleSets;
import org.op.service.log.LoggerService;
import org.op.util.MessageController;

public class DocumentInsertionControllerImpl implements
		DocumentInsertionController {

	private FrameView frameView;
	private ConfigurationService configService;
	private MessageController messageController;
	private EditorComponentView editorView;
	private StyleSets styleSets;
	private LoggerService logger;
	
	public void insertTextIntoCurrentDocument(String text) {
		try {
			int cursorPoint = editorView.getCurrentPane().getCaretPosition();
			Document doc = editorView.getCurrentPane().getDocument();

			styleSets.init();
			
			AttributeSet contentSet = styleSets.getSet(StyleSets.CONTENT_SET);
			doc.insertString(cursorPoint, text, contentSet);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public FrameView getFrameView() {
		return frameView;
	}

	public void setFrameView(FrameView frameView) {
		this.frameView = frameView;
	}

	public ConfigurationService getConfigService() {
		return configService;
	}

	public void setConfigService(ConfigurationService configService) {
		this.configService = configService;
	}

	public MessageController getMessageController() {
		return messageController;
	}

	public void setMessageController(MessageController messageController) {
		this.messageController = messageController;
	}

	public EditorComponentView getEditorView() {
		return editorView;
	}

	public void setEditorView(EditorComponentView editorView) {
		this.editorView = editorView;
	}

	public StyleSets getStyleSets() {
		return styleSets;
	}

	public void setStyleSets(StyleSets styleSets) {
		this.styleSets = styleSets;
	}

	public LoggerService getLogger() {
		return logger;
	}

	public void setLogger(LoggerService logger) {
		this.logger = logger;
	}

}
